# coding=utf-8
""""
方法模式建立线程
"""
from threading import Thread
from time import sleep


def function1(name):
    print(f"线程{name}, start")  # format
    for i in range(3):
        print(f"线程：{name}, {i}")
        sleep(1)
    print(f"线程{name}, end")  # format


if __name__ == "__main__":
    print("主线程，start")
    # 创建线程
    t1 = Thread(target=function1, args=("t1",))
    t2 = Thread(target=function1, args=("t2",))
    # 启动线程
    t1.start()
    t2.start()
    # 主线程会等待t1,t2结束后，再往下执行
    t1.join()
    t2.join()
    print("主线程，end")
